<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel="stylesheet" type="text/css" th:href="@{/css/login.css}" />
	<title>用户登录-松勤商城</title>
	<!-- jquery -->
	<script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
	<!-- bootstrap -->
	<!-- jquery-validator -->
	<script type="text/javascript" th:src="@{/jquery-validation/jquery.validate.min.js}"></script>
	<script type="text/javascript" th:src="@{/jquery-validation/localization/messages_zh.min.js}"></script>
	<!-- layer -->
	<script type="text/javascript" th:src="@{/layer/layer.js}"></script>
	<!-- md5.js -->
	<script type="text/javascript" th:src="@{/js/md5.min.js}"></script>
	<!-- common.js -->
	<script type="text/javascript" th:src="@{/js/common.js}"></script>

</head>
<body>
<div class="sign">
	<form  name="loginForm" id="loginForm"  method="get">
		<ul class="cont">
			<li>
				<span>用户名：</span>
				<input name="mobile" id="mobile" type="text" class="ext" value="13588000000"/>
			</li>
			<li>
				<span>密码：</span><input name="password" id="password" type="password" class="ext" value="111111" required="true" minlength="6" maxlength="16"/>
				<a href="#">忘记密码？</a>
			</li>
			<li>
				<span>验证码：</span>
				<input name="" type="text" class="ext" style="width:130px;"  value="435998" />
				<b><img src="/image/img01.jpg" id="btn2" /></b>
			</li>
			<li class="btn">
				<input id="btn1"  type="submit"   onclick="login()" value="登录" />
			</li>
		</ul>
	</form>
	<div class="controls">
		<div class="main_input_box">
			<h1>2020-现在 songqin.com 版权所有&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;版本号：V6.6  </h1>
		</div>
	</div>
</div>



<script>
	$(function(){
		$("#mobile").focus();

	})

	function login(){
		$("#loginForm").validate({
			submitHandler:function(form){
				doLogin();
			}
		});
	}

	function doLogin(){
		g_showLoading();
		var inputPass = $("#password").val();
		var salt = g_passsword_salt;
		var str = ""+salt.charAt(0)+salt.charAt(2) + inputPass +salt.charAt(5) + salt.charAt(4);
		console.log("加密前："+str)
		var password = md5(str);
		console.log("加密后："+password)

		$.ajax({
			url: "/login/login",
			type: "POST",
			data:{
				mobile:$("#mobile").val(),
				password: password
			},
			success:function(data){
				layer.closeAll();
				if(data.code == 0){
					layer.msg("登录成功！");
					window.location.href="/index.html";
				}else{
					layer.msg(data.msg);
				}
			},
			error:function(){
				layer.closeAll();
			}
		});
	}
</script>

</body>
</html>